home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Networking / ARPSample1.0b1 / OTARPModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-02  |  7.2 KB  |  202 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        OTARPModule.h
  3.  
  4.     Contains:    Types and constants to interface to the OT ARP module.
  5.  
  6.     Written by:    Quinn "The Eskimo!"
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.     You may incorporate this sample code into your applications without
  13.     restriction, though the sample code has been provided "AS IS" and the
  14.     responsibility for its operation is 100% yours.  However, what you are
  15.     not permitted to do is to redistribute the source as "DSC Sample Code"
  16.     after having made changes. If you're going to re-distribute the source,
  17.     we require that you make it clear in the source that the code was
  18.     descended from Apple Sample Code, but that you've made changes.
  19. */
  20.  
  21. #if PRAGMA_ALIGN_SUPPORTED
  22. #pragma options align=mac68k
  23. #endif
  24.  
  25. ///////////////////////////////////////////////////////////////////
  26.  
  27. // Pick up the standard UInt32 types.
  28.  
  29. #include <Types.h>
  30.  
  31. // Pick up the MIOC_CMD macro.
  32.  
  33. #include <OpenTransport.h>
  34.  
  35. // Pick up queue_t.
  36.  
  37. #include <mistream.h>
  38.  
  39. // Pick up the MIOC_ARP constants.
  40.  
  41. // #include <miioccom.h>
  42.  
  43. // This constant is actually defined in <miioccom.h>, but
  44. //  commented out for some reason )-:
  45.  
  46. #define MIOC_ARP        'h'        /* ioctl's for Mentat's arp module */
  47.  
  48. ///////////////////////////////////////////////////////////////////
  49.  
  50. // ARP Command Structures 
  51.  
  52. // arc_t is the standard header for all ARP command structures.
  53. // The structure you should use is determined by the arc_cmd
  54. // field. See the command constants for details of which
  55. // structures to use with which commands..
  56.  
  57. typedef struct {
  58.     UInt32    arc_cmd;
  59.     UInt32    arc_name_offset;
  60.     UInt32    arc_name_length;
  61.     UInt32    arc_proto;
  62.     UInt32    arc_proto_addr_offset;
  63.     UInt32    arc_proto_addr_length;
  64.     UInt32    arc_flags;
  65.     queue_t * arc_client_q;        /* context save area for client module */
  66. } arc_t;
  67.  
  68. typedef    struct {
  69.     arc_t    area_arc;
  70.     UInt32    area_proto_mask_offset;
  71.     UInt32    area_hw_addr_offset;
  72.     UInt32    area_hw_addr_length;
  73. } area_t;
  74.  
  75. typedef    struct {
  76.     arc_t    areq_arc;
  77.     UInt32    areq_sender_addr_offset;
  78.     UInt32    areq_sender_addr_length;
  79.     UInt32    areq_xmit_count;    /* 0 ==> cache lookup only */
  80.     UInt32    areq_xmit_interval;    /* # of milliseconds; 0: default */
  81.     UInt32    areq_max_buffered;    /* # ofquests to buffer; 0: default */
  82.     UInt8    areq_sap[8];        /* to insert in returned template */
  83. } areq_t;
  84.  
  85. typedef    struct {
  86.     arc_t    arma_arc;
  87.     UInt32    arma_proto_mask_offset;
  88.     UInt32    arma_proto_extract_mask_offset;
  89.     UInt32    arma_hw_addr_offset;
  90.     UInt32    arma_hw_addr_length;
  91.     UInt32    arma_hw_mapping_start;    /* Offset to start of the mask&proto_addr */
  92. } arma_t;
  93.  
  94.  
  95. // ARP Command Codes for use in the arc_cmd field of arc_t,
  96. // along with the true structures you should use.
  97.  
  98. #define    AR_ENTRY_ADD        MIOC_CMD(MIOC_ARP,1)
  99. // Add an ARP cache entry.
  100. // Use area_t structure.
  101. // In:
  102. //        area_arc.arc_cmd = AR_ENTRY_ADD
  103. //        area_arc.arc_name_offset = offset to name of interface
  104. //        area_arc.arc_name_length = length of name of interface (including zero terminator)
  105. //        area_arc.arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  106. //        area_arc.arc_proto_addr_offset = offset to protocol address to look up (eg an InetHost)
  107. //        area_arc.arc_proto_addr_offset = length of protocol address to look up (eg sizeof(InetHost))
  108. //        area_arc.arc_flags = flags for this cache entry (see below)
  109. //        area_proto_mask_offset = offset to a protocol address mask (usually $FFFFFFFF)
  110. //        area_hw_addr_offset = offset to hardware address
  111. //        area_hw_addr_length = length of hardware address (eg 6)
  112.  
  113. #define    AR_MAPPING_ADD        MIOC_CMD(MIOC_ARP,7)
  114. // Use arma_t structure.
  115.  
  116. #define    AR_ENTRY_DELETE        MIOC_CMD(MIOC_ARP,2)
  117. // Delete an entry in the ARP cache.
  118. // Use arc_t structure.
  119. // In:
  120. //        arc_cmd = AR_ENTRY_DELETE
  121. //        arc_name_offset = offset to name of interface
  122. //        arc_name_length = length of name of interface (including zero terminator)
  123. //        arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  124. //        arc_proto_addr_offset = offset to protocol address to delete (eg an InetHost)
  125. //        arc_proto_addr_length = length of protocol address to delete (eg sizeof(InetHost))
  126.  
  127. #define    AR_ENTRY_QUERY        MIOC_CMD(MIOC_ARP,3)
  128. // Look for an entry, either in the cache or by talking on the network.
  129. // Use areq_t structure.
  130. // In:
  131. //        areq_arc.arc_cmd = AR_ENTRY_QUERY
  132. //        areq_arc.arc_name_offset = offset to name of interface
  133. //        areq_arc.arc_name_length = length of name of interface (including zero terminator)
  134. //        areq_arc.arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  135. //        areq_arc.arc_proto_addr_offset = offset to protocol address to look up (eg an InetHost)
  136. //        areq_arc.arc_proto_addr_offset = length of protocol address to look up (eg sizeof(InetHost))
  137. //        areq_sender_addr_offset = offset to protocol address of sender (eg an InetHost)
  138. //        areq_sender_addr_length = length of protocol address of sender (eg sizeof(InetHost))
  139. //        areq_xmit_count = number of transmissions before giving up (use 0 for a straight cache lookup)
  140. //        areq_xmit_interval = number of milliseconds between transmissions (0 gives a sensible default)
  141. //        areq_max_buffered = number of requests to buffer (0 gives a sensible default)
  142. //        areq_sap = a SAP to insert into the returned response
  143. // Out:
  144. //        The output is in the form of a DLPI message that you can
  145. //        use as the header to a message to the requested host.
  146.  
  147. #define    AR_ENTRY_SQUERY        MIOC_CMD(MIOC_ARP,6)
  148. // Look for an entry in the ARP cache.
  149. // Use area_t structure.
  150. // In:
  151. //        area_arc.arc_cmd = AR_ENTRY_SQUERY
  152. //        area_arc.arc_name_offset = offset to name of interface
  153. //        area_arc.arc_name_length = length of name of interface (including zero terminator)
  154. //        area_arc.arc_proto = ARP protocol type (eg IP_ARP_PROTO_TYPE)
  155. //        area_arc.arc_proto_addr_offset = offset to protocol address to look up (eg an InetHost)
  156. //        area_arc.arc_proto_addr_offset = length of protocol address to look up (eg sizeof(InetHost))
  157. //        area_hw_addr_offset = offset to buffer to store hardware address
  158. //        area_hw_addr_length = length of buffer to store hardware address (eg 6)
  159. // Out:
  160. //        area_arc.arc_flags = flags for this entry
  161. //        buffer pointed to by area_hw_addr_offset and area_hw_addr_length = hardware address
  162.  
  163. #define    AR_XMIT_REQUEST        MIOC_CMD(MIOC_ARP,4)
  164. // Use arc_t structure.
  165.  
  166. #define    AR_XMIT_RESPONSE    MIOC_CMD(MIOC_ARP,11)
  167. // Use arc_t structure.
  168.  
  169. #define    AR_INTERFACE_UP        MIOC_CMD(MIOC_ARP,9)
  170. // Bring an ARPing interface up.
  171. // Use arc_t structure.
  172. // In:
  173. //        arc_cmd = AR_INTERFACE_UP
  174. //        arc_name_offset = offset to name of interface
  175. //        arc_name_length = length of name of interface (including zero terminator)
  176.  
  177. #define    AR_INTERFACE_DOWN    MIOC_CMD(MIOC_ARP,10)
  178. // Tear an ARPing interface down.
  179. // Use arc_t structure.
  180. // In:
  181. //        arc_cmd = AR_INTERFACE_DOWN
  182. //        arc_name_offset = offset to name of interface
  183. //        arc_name_length = length of name of interface (including zero terminator)
  184.  
  185.  
  186. // Flags used in the arc_flags field of arc_t.
  187.  
  188. #define    ACE_F_PERMANENT        0x1        // This entry will not time out.
  189. #define    ACE_F_PUBLISH        0x2        // ARP will respond to incoming ARP requests for this entry
  190. #define    ACE_F_DYING            0x4        // This entry is going away very soon.
  191. #define    ACE_F_RESOLVED        0x8        // This entry is valid.
  192. #define ACE_F_MAPPING        0x10    // Use bit mask on target address.
  193.  
  194. // The protocol value for IP ARPs, for use in the arc_proto field of the arc_t.
  195.  
  196. #define    IP_ARP_PROTO_TYPE        0x0800
  197.  
  198.  
  199. #if PRAGMA_ALIGN_SUPPORTED
  200. #pragma options align=reset
  201. #endif
  202.